package com.shardingdemo.webmvcConfig;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Description:
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {

    @Bean
    public RequestShardValueInterceptor requestShardValueInterceptor() {
        return new RequestShardValueInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(requestShardValueInterceptor())
                .addPathPatterns("/**");
    }
}
